package com.jstnvr.smartcampus.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jstnvr.smartcampus.entity.Test;
import com.jstnvr.smartcampus.entity.Users;
import com.jstnvr.smartcampus.mapper.UsersMapper;
import com.jstnvr.smartcampus.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public int insertUsers(Users users) {
        return usersMapper.insert(users);
    }

    @Override
    public int deleteByPrimaryKey(String szuid) {

        return usersMapper.deleteByPrimaryKey(szuid);
    }

    @Override
    public int updateByPrimaryKey(Users record) {
        return usersMapper.updateByPrimaryKey(record);
    }

    @Override
    public Users selectByPrimaryKey(String szuid) {



        return usersMapper.selectByPrimaryKey(szuid);
    }

    @Override
    public Users selectByMobile(String mobile) {

        System.out.println(mobile);
        Users user = usersMapper.selectByMbile(mobile);
        return user;
    }

    @Override
    public PageInfo<Users> findAllUsers(int pageNum, int pageSize) {
        //将参数传给这个方法就可以实现物理分页了，非常简单。
        PageHelper.startPage(pageNum, pageSize);
        List<Users> userDomains = usersMapper.selectAllUsers();
        PageInfo result = new PageInfo(userDomains);
        return result;
    }

    @Override
    public Users checkUser(String mobile, String password) {
        return usersMapper.checkUsers(mobile,password);
    }


}
